﻿@model List<LAPI.Data.Model.Pista>
           
@{
    Int32 numeroRegistros = 0;
    if (Model != null)
    {
        numeroRegistros = Model.Count;
    }
        
    WebGrid grid = null;
    if (numeroRegistros > 0) {
        grid = new WebGrid(Model, rowsPerPage: numeroRegistros);
    } else {
        grid = null;
    }
}

<div class="row">
        @if (grid != null)
        {
            @grid.GetHtml(
            fillEmptyRows: true,
            tableStyle: "table table-striped table-bordered",
            mode: WebGridPagerModes.All,
            footerStyle: "badge",

            columns: grid.Columns(
                    grid.Column("idPista", style: "", header: "#", canSort: false),
                    grid.Column("descripcion", style: "", header: "Pista", canSort: false),
                    grid.Column("centroDeportivo", style: "", header: "Centro Deportivo", canSort: false),                    
                    grid.Column("tHoraInicio", style: "", header: "Hora apertura", canSort: false, format: (item) => item.tHoraInicio.ToShortTimeString() ),
                    grid.Column("tHoraFinal", style: "", header: "Hora cierre", canSort: false, format: (item) => item.tHoraFinal.ToShortTimeString() ),
                    grid.Column("luz", style: "", header: "Luz artificial", canSort: false, format: (item) => item.luz ? "Si" : "No"),
                    grid.Column("activo", style: "", header: "En activo", canSort: false, format: (item) => item.activo ? "Si" : "No"),
                    grid.Column(columnName: "",
                                style: "",
                                header: "Acciones",
                                format:
                                        @<text>     
                                            <a class="btn btn-primary" rel="tooltip" title="Ver reservas de Pista" href="@Url.Action(actionName: "ReservasPista", controllerName: "Reservas", routeValues: new { id = @item.idPista })">
                                                <i class="icon-calendar"></i>                                       
                                            </a> 
                                                                          
                                            <a class="btn btn-info" rel="tooltip" title="Editar Centro Deportivo" href="@Url.Action(actionName: "Editar", controllerName: "Pista", routeValues: new { id = @item.idPista })">
                                                <i class="icon-edit"></i>                                       
                                            </a>    
                                                                             
                                            <a class="btn btn-danger" rel="tooltip" title="Eliminar Pista" href="@Url.Action(actionName: "Eliminar", controllerName: "Pista", routeValues: new { id = @item.idPista })" onclick="javascript:return confirmacionEliminar(this, 'pista','@Url.Action(controllerName: "Pista", actionName: "Buscar")');">
                                                <i class="icon-trash"></i>                                        
                                            </a> 
                                     
                                            @if (!item.activo)
                                            {
                                               <a class="btn btn-success" rel="tooltip" title="Activar Pista" href="@Url.Action(actionName: "Activar", controllerName: "Pista", routeValues: new { id = @item.idPista })" onclick="javascript:return confirmacionActivar(this, 'pista','@Url.Action(controllerName: "Pista", actionName: "Buscar")');">
                                                    <i class="icon-ok-circle"></i>                                       
                                               </a> 
                                            } else {
                                               <a class="btn btn-warning" rel="tooltip" title="Desactivar Pista" href="@Url.Action(actionName: "Desactivar", controllerName: "Pista", routeValues: new { id = @item.idPista })" onclick="javascript:return confirmacionDesactivar(this, 'pista','@Url.Action(controllerName: "Pista", actionName: "Buscar")');">
                                                    <i class="icon-ban-circle"></i>                                       
                                               </a> 
                                            }

                                            <a class="btn btn-primary" rel="tooltip" title="Administrar Deportes de Pista" href="@Url.Action(actionName: "Gestion", controllerName: "DeportesPista", routeValues: new { id = @item.idPista })">
                                                <i class="icon-th-list"></i>                                       
                                            </a> 
                                                    
                                        </text>,
                                canSort: false)
                        )
                )  
        }
        else
        {
            <div class="span8 offset1 label label-info">               
                No se han encontrado datos...
            </div>
        }
</div>